from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout
from PyQt5.QtCore import Qt
from .slideshow import PhotoSlideshow
from .fancy_slideshow import FancySlideshow


class HdmiFullScreenWindow(QWidget):
    def __init__(self) -> None:
        super().__init__()
        self.setWindowTitle("Cat Photo UI")
        self.setObjectName("CatPhotoHdmiWindow")

        root_layout = QVBoxLayout(self)
        root_layout.setContentsMargins(0, 0, 0, 0)
        root_layout.setSpacing(0)

        self._content = QLabel("Cat Photo UI - HDMI 输出已就绪")
        self._content.setAlignment(Qt.AlignCenter)
        self._content.setStyleSheet(
            """
            QLabel {
                background-color: #101318;
                color: #D7E0EA;
                font-size: 36px;
                font-weight: 600;
            }
            """
        )
        root_layout.addWidget(self._content)

    def set_slideshow(self, widget: PhotoSlideshow) -> None:
        layout: QVBoxLayout = self.layout()  # type: ignore
        if self._content is not None:
            layout.removeWidget(self._content)
            self._content.deleteLater()
            self._content = None  # type: ignore
        layout.addWidget(widget)

    def set_fancy_slideshow(self, widget: FancySlideshow) -> None:
        layout: QVBoxLayout = self.layout()  # type: ignore
        if self._content is not None:
            layout.removeWidget(self._content)
            self._content.deleteLater()
            self._content = None  # type: ignore
        layout.addWidget(widget)


